<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf"%>
<script type="text/javascript" src="${ctx}/js/client/client_orderplanneradd.js"></script>
<style type="text/css">
.col-sm-3 {
	width: 15%;
	float: left;
}

.col-sm-9 {
	width: 85%;
	float: left;
}

label[class^="btn btn-default"] {
	margin-top: -4px;
}
</style>
</head>
<body>
	<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
	<form id="form" name="form" class="form-horizontal" method="post"
		action="${ctx}/client/client_orderPlanneraddEntity.shtml">
		<input type="hidden" class="form-control checkacc" value="${order.id}"
			name="orderFormMap.id" id="id">
		<section class="panel panel-default">
		<div class="panel-body">
			<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">名称</label>
					<div class="col-sm-9">
						
							 ${order.Name}
					</div>
				</div>
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">订单数量</label>
					<div class="col-sm-9">
						${order.number}
						<input type="hidden" id="number" value="${order.number}"/>
					</div>
				</div>
				<div class="line line-dashed line-lg pull-in"></div>
				<div class="form-group">
					<label class="col-sm-3 control-label">出货日期</label>
					<div class="col-sm-9">
						${order.shipping_time}
						<input type="hidden" id="shiptime" value="${order.shipping_time}"/>
						<input type="hidden" id="current" value="${order.current}"/>
					</div>
				</div>
			</div>
			
			<div class="panel-body">
				<table class="layui-table"  style="font-weight: bold; text-align: center;">
				<thead>
					<tr>
						<th>叫料时间</th>
						<th>需求数量</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><input type="date" name="plannerDate" class="form-control plannerDate" ></td>
						<td><input type="text" name="plannernum" class="form-control plannernum" ></td>
					</tr>
				</tbody>
			</table>
			<button type="button" id="sure" class="btn btn-info marR20">确定</button>
			</div>
		<footer class="panel-footer text-right bg-light lter">
				<button type="submit" class="btn btn-success btn-s-xs">新增</button>
		</footer>
	 </section>
	</form>
<script type="text/javascript">
		$(function(){
			$("#sure").click('click',function(){
				var number=$("#number").val();
				var shipnum=$("#shiptime").val()
				var date=$(".plannerDate:last").val();
				var num=$(".plannernum:last").val();
				var reg=/^\+?[1-9][0-9]*$/;
				var current=$("#current").val();
				if(date==''){
					alert("叫料日期不能为空！");
					return;
				}
				if(shipnum<=date){
					alert("叫料日期不能大于等于最后交货日期");
					$(".plannernum:last").focus();
					return;
				}
				if(current>=date){
					alert("叫料日期不能小于等于今天");
					$(".plannernum:last").focus();
					
					return;
				}
				if(reg.test(num)==false){
					alert("请输入数字");
					$(".plannernum:last").focus().val('');
					return;
				}
				if(parseInt(number)<parseInt(num)){
					alert("数量不足");
					$(".plannerDate:last").focus().val()
					$(".plannernum:last").val('');
					return;
				}
				var html="<tr><td><input type='date' name='plannerDate'  class='form-control plannerDate'></td><td><input type='text' name='plannernum' class='form-control plannernum'></td></tr>"
				$(".plannernum:last").attr("readonly",true);
				$(".plannerDate:last").attr("readonly",true);
				$("tbody").append(html);
				$("#number").val(number-=num);
			});
		});
</script> 
</body>
</html>